class PlayersController < ApplicationController
	def index
		@players = Player.all
		@players = @players.sort_by{|p| [-p.score, p.games_played, p.name]}
	end
	def show
		@id = params[:id]
		@player = Player.find @id
		@pairs = @player.pairs.select{|pair| pair.played == false}
		@wins = @player.pairs.select{|pair| pair.played == true && pair.score > 0}
		@losses = @player.pairs.select{|pair| pair.played == true && pair.score == 0}
	end
	def new
		@player = Player.new
	end
	def create
		Player.create(params[:player])
		redirect_to players_path
	end
end
